package scuts.core.macros;
import utest.Assert;

import scuts.core.macros.F;
/**
 * ...
 * @author $(DefaultUser)
 */

class FacTest  
{

  public function new() 
  {
    
  }

  public function testSimple () 
    {
      var expected = [0,1,2,3];
      var actual = F.ac(x, x <= 0...4);
      
      Assert.same(expected, actual, true);
      
    }
    
  public function testNested () 
    {
      var expected = [0,1,0,1];
      var actual = F.ac(x, x <= 0...2, y <= 0...2);
      
      Assert.same(expected, actual, true);
      
    }
    
  public function testMultiple () 
    {
      var expected = [[0, 0], [1, 1]];
      var actual = F.ac([x1,x2], x1 <= 0...2 && x2 <= 0...2);
      Assert.same(expected, actual, true);
    }
  
  public function testMultipleAndNested () 
    {
      var expected = [[0, 0], [1, 1], [0, 0], [1, 1]];
      var actual = F.ac([x1,x2], x1 <= 0...2 && x2 <= 0...2, y <= 0...2);
      Assert.same(expected, actual, true);
    }
    
  public function testGuard1 () 
    {
      var expected = [0,2,3];
      var actual = F.ac(x, x <= 0...4 || x != 1);
      Assert.same(expected, actual, true);
    }
    
  public function testNestedGuards () 
    {
      var expected = [1];
      var actual = F.ac(x, x <= 0...2 || x != 0, y <= 0...2 || y != 0);
      Assert.same(expected, actual, true);
    }
    
  public function testGeneratorsWithDifferentSize () 
    {
      var expected = [0,1];
      var actual = F.ac(x, x <= 0...2 && y <= 0...100000);
      Assert.same(expected, actual, true);
    }
    
  public function testIfOutputFunctionDoesntChangeLoopVar () 
    {
      var expected = [0,1,2,3];
      var actual = F.ac( { var y = x; x = 17; y; }, x <= 0...4);
      Assert.same(expected, actual, true);
    }
    
  public function testIfPredicateDoesntChangeLoopVar () 
    {
      var expected = [0, 1, 2, 3];
      var actual = F.ac( x, x <= 0...4 || { x = 17; true;});
      Assert.same(expected, actual, true);
    }
}